﻿namespace HutongGames.PlayMaker
{
    using System;
    using System.Collections.Generic;
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    using UnityEngine;

    [Serializable]
    public class FsmEvent : IComparable, INameable
    {
        [CompilerGenerated]
        private static FsmEvent BecameInvisible__BackingField;
        [CompilerGenerated]
        private static FsmEvent BecameVisible__BackingField;
        [CompilerGenerated]
        private static FsmEvent CollisionEnter__BackingField;
        [CompilerGenerated]
        private static FsmEvent CollisionExit__BackingField;
        [CompilerGenerated]
        private static FsmEvent CollisionStay__BackingField;
        [CompilerGenerated]
        private static FsmEvent ConnectedToServer__BackingField;
        [CompilerGenerated]
        private static FsmEvent ControllerColliderHit__BackingField;
        [CompilerGenerated]
        private static FsmEvent DisconnectedFromServer__BackingField;
        [CompilerGenerated]
        private static FsmEvent FailedToConnect__BackingField;
        [CompilerGenerated]
        private static FsmEvent FailedToConnectToMasterServer__BackingField;
        [CompilerGenerated]
        private static FsmEvent Finished__BackingField;
        [CompilerGenerated]
        private static FsmEvent LevelLoaded__BackingField;
        [CompilerGenerated]
        private static FsmEvent MasterServerEvent__BackingField;
        [CompilerGenerated]
        private static FsmEvent MouseDown__BackingField;
        [CompilerGenerated]
        private static FsmEvent MouseDrag__BackingField;
        [CompilerGenerated]
        private static FsmEvent MouseEnter__BackingField;
        [CompilerGenerated]
        private static FsmEvent MouseExit__BackingField;
        [CompilerGenerated]
        private static FsmEvent MouseOver__BackingField;
        [CompilerGenerated]
        private static FsmEvent MouseUp__BackingField;
        [CompilerGenerated]
        private static FsmEvent NetworkInstantiate__BackingField;
        [CompilerGenerated]
        private string Path__BackingField;
        [CompilerGenerated]
        private static FsmEvent PlayerConnected__BackingField;
        [CompilerGenerated]
        private static FsmEvent PlayerDisconnected__BackingField;
        [CompilerGenerated]
        private static FsmEvent ServerInitialized__BackingField;
        [CompilerGenerated]
        private static FsmEvent TriggerEnter__BackingField;
        [CompilerGenerated]
        private static FsmEvent TriggerExit__BackingField;
        [CompilerGenerated]
        private static FsmEvent TriggerStay__BackingField;
        private static List<FsmEvent> eventList;
        [SerializeField]
        private bool isSystemEvent;
        [SerializeField]
        private string name;

        public FsmEvent(FsmEvent source)
        {
            this.name = source.name;
            this.isSystemEvent = source.isSystemEvent;
        }

        public FsmEvent(string name)
        {
            this.name = name;
            if (!EventListContainsEvent(EventList, name))
            {
                EventList.Add(this);
            }
        }

        public static FsmEvent AddFsmEvent(FsmEvent fsmEvent)
        {
            eventList.Add(fsmEvent);
            return fsmEvent;
        }

        private static void AddGlobalEvents()
        {
            foreach (string str in globalEvents)
            {
                new FsmEvent(str);
            }
        }

        private static FsmEvent AddSystemEvent(string eventName, [Optional, DefaultParameterValue("")] string path)
        {
            FsmEvent event2 = new FsmEvent(eventName);
            event2.IsSystemEvent = true;
            event2.Path = (path == "") ? "" : (path + "/");
            return event2;
        }

        private static void AddSystemEvents()
        {
            BecameInvisible = AddSystemEvent("BECAME INVISIBLE", "System Events");
            BecameVisible = AddSystemEvent("BECAME VISIBLE", "System Events");
            CollisionEnter = AddSystemEvent("COLLISION ENTER", "System Events");
            CollisionExit = AddSystemEvent("COLLISION EXIT", "System Events");
            CollisionStay = AddSystemEvent("COLLISION STAY", "System Events");
            ControllerColliderHit = AddSystemEvent("CONTROLLER COLLIDER HIT", "System Events");
            Finished = AddSystemEvent("FINISHED", "System Events");
            LevelLoaded = AddSystemEvent("LEVEL LOADED", "System Events");
            MouseDown = AddSystemEvent("MOUSE DOWN", "System Events");
            MouseDrag = AddSystemEvent("MOUSE DRAG", "System Events");
            MouseEnter = AddSystemEvent("MOUSE ENTER", "System Events");
            MouseExit = AddSystemEvent("MOUSE EXIT", "System Events");
            MouseOver = AddSystemEvent("MOUSE OVER", "System Events");
            MouseUp = AddSystemEvent("MOUSE UP", "System Events");
            TriggerEnter = AddSystemEvent("TRIGGER ENTER", "System Events");
            TriggerExit = AddSystemEvent("TRIGGER EXIT", "System Events");
            TriggerStay = AddSystemEvent("TRIGGER STAY", "System Events");
            PlayerConnected = AddSystemEvent("PLAYER CONNECTED", "Network Events");
            ServerInitialized = AddSystemEvent("SERVER INITIALIZED", "Network Events");
            ConnectedToServer = AddSystemEvent("CONNECTED TO SERVER", "Network Events");
            PlayerDisconnected = AddSystemEvent("PLAYER DISCONNECTED", "Network Events");
            DisconnectedFromServer = AddSystemEvent("DISCONNECTED FROM SERVER", "Network Events");
            FailedToConnect = AddSystemEvent("FAILED TO CONNECT", "Network Events");
            FailedToConnectToMasterServer = AddSystemEvent("FAILED TO CONNECT TO MASTER SERVER", "Network Events");
            MasterServerEvent = AddSystemEvent("MASTER SERVER EVENT", "Network Events");
            NetworkInstantiate = AddSystemEvent("NETWORK INSTANTIATE", "Network Events");
        }

        public static bool EventListContains(string eventName)
        {
            return (FindEvent(eventName) != null);
        }

        public static bool EventListContainsEvent(List<FsmEvent> fsmEventList, string fsmEventName)
        {
            if ((fsmEventList != null) && !string.IsNullOrEmpty(fsmEventName))
            {
                foreach (FsmEvent event2 in fsmEventList)
                {
                    if (event2.Name == fsmEventName)
                    {
                        return true;
                    }
                }
            }
            return false;
        }

        public static FsmEvent FindEvent(string eventName)
        {
            foreach (FsmEvent event2 in EventList)
            {
                if (event2.name == eventName)
                {
                    return event2;
                }
            }
            return null;
        }

        public static FsmEvent GetFsmEvent(FsmEvent fsmEvent)
        {
            if (fsmEvent == null)
            {
                return null;
            }
            foreach (FsmEvent event2 in EventList)
            {
                if (string.CompareOrdinal(event2.Name, fsmEvent.Name) == 0)
                {
                    return (Application.isPlaying ? event2 : new FsmEvent(event2));
                }
            }
            if (fsmEvent.isSystemEvent)
            {
                Debug.LogError("Missing System Event: " + fsmEvent.Name);
            }
            return AddFsmEvent(fsmEvent);
        }

        public static FsmEvent GetFsmEvent(string eventName)
        {
            foreach (FsmEvent event2 in EventList)
            {
                if (string.CompareOrdinal(event2.Name, eventName) == 0)
                {
                    return (Application.isPlaying ? event2 : new FsmEvent(event2));
                }
            }
            FsmEvent source = new FsmEvent(eventName);
            if (!Application.isPlaying)
            {
                return new FsmEvent(source);
            }
            return source;
        }

        public static bool IsEventGlobal(string eventName)
        {
            return globalEvents.Contains(eventName);
        }

        public static bool IsNullOrEmpty(FsmEvent fsmEvent)
        {
            if (fsmEvent != null)
            {
                return string.IsNullOrEmpty(fsmEvent.name);
            }
            return true;
        }

        public static void RemoveEventFromEventList(FsmEvent fsmEvent)
        {
            if (fsmEvent.isSystemEvent)
            {
                Debug.LogError("RemoveEventFromEventList: Trying to delete System Event: " + fsmEvent.Name);
            }
            EventList.Remove(fsmEvent);
        }

        public static void SanityCheckEventList()
        {
            List<FsmEvent> fsmEventList = new List<FsmEvent>();
            foreach (FsmEvent event2 in EventList)
            {
                if (!EventListContainsEvent(fsmEventList, event2.Name))
                {
                    fsmEventList.Add(event2);
                }
            }
            eventList = fsmEventList;
        }

        int IComparable.CompareTo(object obj)
        {
            FsmEvent event2 = (FsmEvent) obj;
            if (this.isSystemEvent && !event2.isSystemEvent)
            {
                return -1;
            }
            if (!this.isSystemEvent && event2.isSystemEvent)
            {
                return 1;
            }
            return this.name.CompareTo(event2.name);
        }

        public static FsmEvent BecameInvisible
        {
            [CompilerGenerated]
            get
            {
                return BecameInvisible__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                BecameInvisible__BackingField = value;
            }
        }

        public static FsmEvent BecameVisible
        {
            [CompilerGenerated]
            get
            {
                return BecameVisible__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                BecameVisible__BackingField = value;
            }
        }

        public static FsmEvent CollisionEnter
        {
            [CompilerGenerated]
            get
            {
                return CollisionEnter__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                CollisionEnter__BackingField = value;
            }
        }

        public static FsmEvent CollisionExit
        {
            [CompilerGenerated]
            get
            {
                return CollisionExit__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                CollisionExit__BackingField = value;
            }
        }

        public static FsmEvent CollisionStay
        {
            [CompilerGenerated]
            get
            {
                return CollisionStay__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                CollisionStay__BackingField = value;
            }
        }

        public static FsmEvent ConnectedToServer
        {
            [CompilerGenerated]
            get
            {
                return ConnectedToServer__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                ConnectedToServer__BackingField = value;
            }
        }

        public static FsmEvent ControllerColliderHit
        {
            [CompilerGenerated]
            get
            {
                return ControllerColliderHit__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                ControllerColliderHit__BackingField = value;
            }
        }

        public static FsmEvent DisconnectedFromServer
        {
            [CompilerGenerated]
            get
            {
                return DisconnectedFromServer__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                DisconnectedFromServer__BackingField = value;
            }
        }

        public static List<FsmEvent> EventList
        {
            get
            {
                if (eventList == null)
                {
                    eventList = new List<FsmEvent>();
                    AddSystemEvents();
                    AddGlobalEvents();
                }
                return eventList;
            }
        }

        public static FsmEvent FailedToConnect
        {
            [CompilerGenerated]
            get
            {
                return FailedToConnect__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                FailedToConnect__BackingField = value;
            }
        }

        public static FsmEvent FailedToConnectToMasterServer
        {
            [CompilerGenerated]
            get
            {
                return FailedToConnectToMasterServer__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                FailedToConnectToMasterServer__BackingField = value;
            }
        }

        public static FsmEvent Finished
        {
            [CompilerGenerated]
            get
            {
                return Finished__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                Finished__BackingField = value;
            }
        }

        public static List<string> globalEvents
        {
            get
            {
                return PlayMakerGlobals.Instance.Events;
            }
        }

        public static PlayMakerGlobals GlobalsComponent
        {
            get
            {
                return PlayMakerGlobals.Instance;
            }
        }

        public bool IsGlobal
        {
            get
            {
                return globalEvents.Contains(this.name);
            }
            set
            {
                if (value)
                {
                    if (!globalEvents.Contains(this.name))
                    {
                        globalEvents.Add(this.name);
                    }
                }
                else
                {
                    globalEvents.Remove(this.name);
                }
            }
        }

        public bool IsSystemEvent
        {
            get
            {
                return this.isSystemEvent;
            }
            set
            {
                this.isSystemEvent = value;
            }
        }

        public static FsmEvent LevelLoaded
        {
            [CompilerGenerated]
            get
            {
                return LevelLoaded__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                LevelLoaded__BackingField = value;
            }
        }

        public static FsmEvent MasterServerEvent
        {
            [CompilerGenerated]
            get
            {
                return MasterServerEvent__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                MasterServerEvent__BackingField = value;
            }
        }

        public static FsmEvent MouseDown
        {
            [CompilerGenerated]
            get
            {
                return MouseDown__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                MouseDown__BackingField = value;
            }
        }

        public static FsmEvent MouseDrag
        {
            [CompilerGenerated]
            get
            {
                return MouseDrag__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                MouseDrag__BackingField = value;
            }
        }

        public static FsmEvent MouseEnter
        {
            [CompilerGenerated]
            get
            {
                return MouseEnter__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                MouseEnter__BackingField = value;
            }
        }

        public static FsmEvent MouseExit
        {
            [CompilerGenerated]
            get
            {
                return MouseExit__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                MouseExit__BackingField = value;
            }
        }

        public static FsmEvent MouseOver
        {
            [CompilerGenerated]
            get
            {
                return MouseOver__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                MouseOver__BackingField = value;
            }
        }

        public static FsmEvent MouseUp
        {
            [CompilerGenerated]
            get
            {
                return MouseUp__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                MouseUp__BackingField = value;
            }
        }

        public string Name
        {
            get
            {
                return this.name;
            }
            set
            {
                this.name = value;
            }
        }

        public static FsmEvent NetworkInstantiate
        {
            [CompilerGenerated]
            get
            {
                return NetworkInstantiate__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                NetworkInstantiate__BackingField = value;
            }
        }

        public string Path
        {
            [CompilerGenerated]
            get
            {
                return this.Path__BackingField;
            }
            [CompilerGenerated]
            set
            {
                this.Path__BackingField = value;
            }
        }

        public static FsmEvent PlayerConnected
        {
            [CompilerGenerated]
            get
            {
                return PlayerConnected__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                PlayerConnected__BackingField = value;
            }
        }

        public static FsmEvent PlayerDisconnected
        {
            [CompilerGenerated]
            get
            {
                return PlayerDisconnected__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                PlayerDisconnected__BackingField = value;
            }
        }

        public static FsmEvent ServerInitialized
        {
            [CompilerGenerated]
            get
            {
                return ServerInitialized__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                ServerInitialized__BackingField = value;
            }
        }

        public static FsmEvent TriggerEnter
        {
            [CompilerGenerated]
            get
            {
                return TriggerEnter__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                TriggerEnter__BackingField = value;
            }
        }

        public static FsmEvent TriggerExit
        {
            [CompilerGenerated]
            get
            {
                return TriggerExit__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                TriggerExit__BackingField = value;
            }
        }

        public static FsmEvent TriggerStay
        {
            [CompilerGenerated]
            get
            {
                return TriggerStay__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                TriggerStay__BackingField = value;
            }
        }
    }
}

